/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function findCustomer1(offset) {
    var name = $d("customerName").value;
    if( name == null ) name = "";
    var ls = service.findCustomer(offset, name);
    var jTable = new JTable();
    jTable.setTableId("tablecustomer");
    jTable.setColumns(["Name", "Bill Name", "Type"]);
    jTable.setFields(["customerName","billName","customerTypeName"]);
    jTable.setEditFunction("setCustomer");
    jTable.setEditEnable(true);
    jTable.setDeleteFunction("");
    jTable.setDeleteEnable(false);
    jTable.setAlignment("cols[0]='center';cols[1]='center';cols[2]='center'");
    jTable.setDataId("customerId");
    jTable.setCount(10);        
    jTable.setOffset(0);
    jTable.setDataPageSize(20);
    jTable.setPageLink("findCustomer");
    jTable.setTableHeader();
    jTable.loadData(ls);
}
function showCustomerPanel1() {
    clearCustomer1(); 
    var divcal = document.getElementById("div_customer_panel");
    var width =  window.innerWidth;
    var height = window.innerHeight;
    divcal.style.width = 574+"px";
    divcal.style.height= 560+"px";
    var left2 = ((width/2) - (574/2));
    var top2 = ((height/2) - (560/2));
    divcal.style.borderStyle = "ridge";
    divcal.style.borderWidth = "medium";
    divcal.style.top = top2+"px";
    divcal.style.left = left2+"px";
    divcal.style.visibility = "visible";
    findCustomer1(0);
}
function closeCustomerPanel1() {
    var divcal = document.getElementById("div_customer_panel");
    divcal.style.visibility = "hidden";
}
function clearCustomer1() {
    //if( adminMode == true ) {
        $d('customerName').value = "";
        $d('customerId').value = "";
    //}
}
function setCustomer(id) {
    var c = service.findCustomerById(id);
    $d('customerName').value = c.customerName;
    $d('customerId').value = c.customerId;
    closeCustomerPanel1();
}

function invoiceReport() {
    var ft = $d('fromTime').value;
    var tt = $d('toTime').value;
    var cid = $d('customerId').value;
    var params = 'fromTime='+ escape(ft) +'&toTime='+ escape(tt) +'&customerId='+cid ;
    window.open('invoice?'+params,'Invoice Report','width=600,height=400');
}
